<template>
  <div>
    <el-breadcrumb separator="/">
        <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
        <el-breadcrumb-item>权限管理</el-breadcrumb-item>
        <el-breadcrumb-item>权限列表</el-breadcrumb-item>
    </el-breadcrumb>

    <el-card class="box-card">
      <el-table
        :data="tableData"
        border
        style="width: 100%">
        <el-table-column
          type="index"
          label="#"
          width="40">
        </el-table-column>
        <el-table-column
          prop="authName"
          label="权限名称">
        </el-table-column>
        <el-table-column
          prop="path"
          label="路径">
        </el-table-column>
        <el-table-column
          prop="level"
          label="权限等级">
            <template slot-scope="scope">
              <el-tag :type="typeArr[scope.row.level]">{{scope.row.level | rank}}</el-tag>
              
              <!-- 一种方法 -->
              <!-- <el-tag v-if="scope.row.level == 0">一级</el-tag>
              <el-tag type="success" v-else-if="scope.row.level ==1">二级</el-tag>
              <el-tag type="warning" v-else>三级</el-tag> -->
            </template>
        </el-table-column>
      </el-table>
    </el-card>

     
  </div>
</template>

<script>
import { rightApi } from "../../http/api";
export default {
  data() {
    return {
      // 表格数据
      tableData:[],
      // 等级
      typeArr:{
        0:'primary',
        1:'success',
        2:'warning',
      },
    }
  },
  created(){
    this.getRightslist()
  },
  methods:{
    // 渲染
   async getRightslist(){
    const res = await rightApi()
    console.log(res);
    this.tableData = res
   }
  }
}
</script>

<style>

</style>